#!/bin/bash

set -e  # 脚本出错时立即终止

echo "=== Begin ==="

# 保存当前路径
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# 进入 workload 目录
cd "$SCRIPT_DIR/../../workload"
echo "[INFO] Using workload/build/main.bin "

if [ ! -f build/main.bin ]; then
    make clean
    make
fi

cd "$SCRIPT_DIR"

mkdir -p build
cp ../../workload/build/main.bin ./build/Image

cd build
xxd -i Image > Image.h
echo "[INFO] xxd -i Image > Image.h"

echo "===  End  ==="